import { History,createBrowserHistory } from 'history';
export default class GlobalHistoryManager
{
    constructor(private readonly globalVarName:string="__global_history"){}
    static instance(){
        return new GlobalHistoryManager();
    }
    getHistoryObject():History<any>{
        if(!this.isHObjectOK()){
            this.initHObject();
        }
        return this.readHObject();
    }
    navigateTo(path:string){
        this.getHistoryObject().push(path);
    }
    private isHObjectOK():boolean{
        return this.getWindow()[this.globalVarName];
    }
    private initHObject(){
        this.getWindow()[this.globalVarName] = createBrowserHistory();
    }
    private readHObject():History{
        return this.getWindow()[this.globalVarName];
    }
    private getWindow():Window{
        return <any>window;
    }
}